define(function () {
	var EncaRouter = function () {
		this.routes = {};
		this.currentUrl = '';
	}

	EncaRouter.prototype.route = function (path, callback) {
		this.routes[path] = callback || function () {};
	}

	EncaRouter.prototype.refresh = function () {
		this.currentUrl = location.hash.slice(1) || '/index'
		if(typeof this.routes[this.currentUrl] === 'function') this.routes[this.currentUrl]();
	}

	EncaRouter.prototype.init = function () {
		window.addEventListener('hashchange', this.refresh.bind(this), false);
	}

	EncaRouter.prototype._gopage = function (routerurl) {
		if (typeof this.routes[routerurl] === 'function') this.routes[routerurl]();
	}

	return EncaRouter;
});